/*
    SUSAN® - Sole of Unix Save ANything

   Copyright (C) 2002-2009 Hechzh Property
   Copyright (C) 2016-2016 Skyatlas Co. CN

   
*/
/*
 * Kern Sibbald, December MMII
 */
/**
 * @file
 * Watchdog timer routines
 */
#ifndef BAREOS_LIB_WATCHDOG_H_
#define BAREOS_LIB_WATCHDOG_H_

#include "lib/dlist.h"

enum
{
  TYPE_CHILD = 1,
  TYPE_PTHREAD,
  TYPE_BSOCK
};

#define TIMEOUT_SIGNAL SIGUSR2

struct s_watchdog_t {
  bool one_shot;
  utime_t interval;
  void (*callback)(struct s_watchdog_t* wd);
  void (*destructor)(struct s_watchdog_t* wd);
  void* data;
  /* Private data below - don't touch outside of watchdog.c */
  dlink link;
  utime_t next_fire;
};
typedef struct s_watchdog_t watchdog_t;

/* Exported globals */
extern utime_t watchdog_time;       /* this has granularity of SLEEP_TIME */
extern utime_t watchdog_sleep_time; /* examine things every 60 seconds */
int StartWatchdog(void);
int StopWatchdog(void);
watchdog_t* new_watchdog(void);
bool RegisterWatchdog(watchdog_t* wd);
bool UnregisterWatchdog(watchdog_t* wd);
bool IsWatchdog();

#endif /* BAREOS_LIB_WATCHDOG_H_ */
